<?php
    require_once("config.php");
    //error_reporting(E_ALL);
    $menu = new Menu("Getting Started");
    $menu->AddItem(new MenuItem("RPI Student Login","login.php?method=cas", AuthConstants::NOT_LOGGED_IN));
    $menu->AddItem(new MenuItem("Guest and Landlord Login","login.php", AuthConstants::NOT_LOGGED_IN));
    $menu->AddItem(new MenuItem("&nbsp;","#",AuthConstants::NOT_LOGGED_IN));
    $menu->AddItem(new MenuItem("Request Guest Account","guest.php", AuthConstants::NOT_LOGGED_IN));
	$menu->AddItem(new MenuItem("Create Landlord Account","guest.php?type=landlord", AuthConstants::NOT_LOGGED_IN));
    MenuManager::AddMenu("Home",$menu);
    
    
    Functions::PrintHeader("Home");

    $contentblocks = array();
    if (AuthManager::AuthLevelMatches(array(AuthConstants::STUDENTS,AuthConstants::GUESTS))) {
        $query = "SELECT * FROM listings WHERE listed=1 ORDER BY postedon DESC LIMIT 3;";
        $listings = DBM::FetchAllRows($query);
        $buf = '';
        foreach ($listings as $listing) {
            $lr = new ListingRow($listing['id']);
            $buf .= $lr->Render(true);
        }
        $contentblocks[] = new HeaderTextPair("Recently Added Listings",$buf);
    }
    else if (AuthManager::AuthLevelMatches(AuthConstants::LANDLORDS)) {
        $contentblocks[] = new HeaderTextPair("Edit or Set Up Your Profile","Modify your contact information, profile picture");
        $contentblocks[] = new HeaderTextPair("Set up your listings","Create, Edit, and Delete listings");
    }
    else {
        $contentblocks[] = new HeaderTextPair("Don't have an RCS account?","You can register for a 90-day guest account <a href='guest.php'>here</a>");
        $contentblocks[] = new HeaderTextPair("Are you a landlord seeking access?","Register for a landlord account <a href='guest.php?type=landlord'>here</a>");
    }

    $contentblocks[] = new HeaderTextPair("Bugs and Errors","This software is still very new.  If you find any bugs, errors, problems, etc., please let me know about them <a href='contact.php'>HERE</a>.");
//    $contentblocks[] = new HeaderTextPair("Google Maps","Currently Google Maps functionality is being worked into the program.  Upon completion the use of Google Maps will allow you to view the apartment on a map as well as do searches based on distance from campus.");
    
    foreach ($contentblocks as $panel) {
        echo $panel->__toString() . "<br /><br />";
    }
    Functions::PrintFooter();
?>
